﻿using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using CRM.MODEL;
using CRM.UTIL;

namespace CRM.DAL
{
    public class PartsD : DBChannel
    {
        /// <summary>
        /// 可以在此选择数据库连接，默认为CRM
        /// </summary>
        public PartsD() : base()
        {
        }


        #region 执行存储过程 Pro_GetParts ,根据条件获取回馈信息

        /// <summary>
        /// 执行存储过程 Pro_GetParts 
        ///xialei
        /// </summary>

        public DataTable ExecuteGetParts(ref CRM.MODEL.GetParts stu)
        {
            //存储过程参数	 		     
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.IDPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.GUIDPARM, SqlDbType.VarChar));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.CATEGORYIDPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PARTSSUPPLIERIDPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.WISETECHPARTSNOPARM, SqlDbType.VarChar, 30));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.SUPPLIERPARTSNOPARM, SqlDbType.VarChar, 30));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PARTSNAMEPARM, SqlDbType.VarChar, 100));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PARTSDISPLAYNAMEPARM, SqlDbType.VarChar, 100));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.MATERIALSPECIFICATIONPARM, SqlDbType.VarChar,
                200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PROCUREMENTPRICEPARM, SqlDbType.Decimal));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PROCUREMENTCURRENCYPARM, SqlDbType.VarChar,
                10));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.MARKETPRICEPARM, SqlDbType.Decimal));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.MARKETCURRENCYPARM, SqlDbType.VarChar, 10));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.GETGOODSDAYSPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PAYGOODSDAYSPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.STOCKQUANTITYPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.LEASTSELLCOUNTPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.REMARKPARM, SqlDbType.VarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.ISAVAILABLEPARM, SqlDbType.Bit));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.CREATEBYPARM, SqlDbType.VarChar, 20));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.CREATETIMEPARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.LASTMODIFYBYPARM, SqlDbType.VarChar, 20));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.LASTMODIFYTIMEPARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.KEYVALUEPARM, SqlDbType.VarChar));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.WISETECHPARTSNOKEYVALUEPARM, SqlDbType.VarChar));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.SUPPLIERPARTSNOKEYVALUEPARM, SqlDbType.VarChar));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PROCUREMENTPRICESTARTPARM, SqlDbType.Decimal));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PROCUREMENTPRICEENDPARM, SqlDbType.Decimal));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.MARKETPRICESTARTPARM, SqlDbType.Decimal));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.MARKETPRICEENDPARM, SqlDbType.Decimal));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.STOCKQUANTITYSTARTPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.STOCKQUANTITYENDPARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PARTSMODELIDSPARM, SqlDbType.VarChar));

            //分页参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.ORDERSTRING_PARM, SqlDbType.VarChar, 1000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.PAGESIZE_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.CURRENTPAGEINDEX_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetParts.TOTALITEMS_PARM, SqlDbType.Decimal));

            //设置参数的值
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.IDPARM].Value = stu.IDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.GUIDPARM].Value = stu.GUIDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.CATEGORYIDPARM].Value = stu.CATEGORYIDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PARTSSUPPLIERIDPARM].Value = stu.PARTSSUPPLIERIDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.WISETECHPARTSNOPARM].Value = stu.WISETECHPARTSNOVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.SUPPLIERPARTSNOPARM].Value = stu.SUPPLIERPARTSNOVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PARTSNAMEPARM].Value = stu.PARTSNAMEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PARTSDISPLAYNAMEPARM].Value = stu.PARTSDISPLAYNAMEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.MATERIALSPECIFICATIONPARM].Value = stu.MATERIALSPECIFICATIONVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PROCUREMENTPRICEPARM].Value = stu.PROCUREMENTPRICEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PROCUREMENTCURRENCYPARM].Value = stu.PROCUREMENTCURRENCYVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.MARKETPRICEPARM].Value = stu.MARKETPRICEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.MARKETCURRENCYPARM].Value = stu.MARKETCURRENCYVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.GETGOODSDAYSPARM].Value = stu.GETGOODSDAYSVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PAYGOODSDAYSPARM].Value = stu.PAYGOODSDAYSVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.STOCKQUANTITYPARM].Value = stu.STOCKQUANTITYVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.LEASTSELLCOUNTPARM].Value = stu.LeastSellCountVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.REMARKPARM].Value = stu.REMARKVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.ISAVAILABLEPARM].Value = stu.ISAVAILABLEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.CREATEBYPARM].Value = stu.CREATEBYVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.CREATETIMEPARM].Value = stu.CREATETIMEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.LASTMODIFYBYPARM].Value = stu.LASTMODIFYBYVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.LASTMODIFYTIMEPARM].Value = stu.LASTMODIFYTIMEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.KEYVALUEPARM].Value = stu.KEYVALUEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.WISETECHPARTSNOKEYVALUEPARM].Value = stu.WISETECHPARTSNOKEYVALUEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.SUPPLIERPARTSNOKEYVALUEPARM].Value = stu.SUPPLIERPARTSNOKEYVALUEVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PROCUREMENTPRICESTARTPARM].Value = stu.PROCUREMENTPRICESTARTVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PROCUREMENTPRICEENDPARM].Value = stu.PROCUREMENTPRICEENDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.MARKETPRICESTARTPARM].Value = stu.MARKETPRICESTARTVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.MARKETPRICEENDPARM].Value = stu.MARKETPRICEENDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.STOCKQUANTITYSTARTPARM].Value = stu.STOCKQUANTITYSTARTVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.STOCKQUANTITYENDPARM].Value = stu.STOCKQUANTITYENDVALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PARTSMODELIDSPARM].Value = stu.PARTSMODELIDSVALUE;

            //设置分页参数的值
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.ORDERSTRING_PARM].Value = stu.ORDERSTRING_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.PAGESIZE_PARM].Value = stu.PAGESIZE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.CURRENTPAGEINDEX_PARM].Value = stu.CURRENTPAGEINDEX_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.TOTALITEMS_PARM].Value = stu.TOTALITEMS_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetParts.TOTALITEMS_PARM].Direction = ParameterDirection.Output;

            //执行
            DataTable dt = this.GetDataByProcedure("dbo.Pro_GetParts");
            //获取数据库的信息
            stu.TOTALITEMS_VALUE = this.sqlCmd.Parameters[CRM.MODEL.GetParts.TOTALITEMS_PARM].Value;

            return dt;
        }

        #endregion

        #region 执行存储过程 Pro_EditParts,根据条件获取回馈信息

        /// <summary>
        /// 执行存储过程 Pro_EditParts 的相关参数
        ///xialei
        /// </summary>
        public int ExecuteEditParts(ref CRM.MODEL.EditParts stu)
        {
            if ((string) stu.ACTION_VALUE == "Update")
            {
                #region Update

                var sqlSb = new StringBuilder();
                sqlCmd.Parameters.Clear();
                sqlSb.Append(" UPDATE Parts SET ");

                if (stu.ID_VALUE != DBNull.Value)
                {
                }
                if (stu.GUID_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" [Guid]=@Guid,");
                    sqlCmd.Parameters.Add(new SqlParameter("@Guid", stu.GUID_VALUE));
                }
                if (stu.CATEGORYID_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" CategoryID=@CategoryID,");
                    sqlCmd.Parameters.Add(new SqlParameter("@CATEGORYID", stu.CATEGORYID_VALUE));
                }
                if (stu.PARTSSUPPLIERID_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" PartsSupplierID=@PartsSupplierID,");
                    sqlCmd.Parameters.Add(new SqlParameter("@PARTSSUPPLIERID", stu.PARTSSUPPLIERID_VALUE));
                }
                if (stu.WISETECHPARTSNO_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" WisetechPartsNO=@WisetechPartsNO,");
                    sqlCmd.Parameters.Add(new SqlParameter("@WISETECHPARTSNO", stu.WISETECHPARTSNO_VALUE));
                }
                if (stu.SUPPLIERPARTSNO_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" SupplierPartsNO=@SupplierPartsNO,");
                    sqlCmd.Parameters.Add(new SqlParameter("@SUPPLIERPARTSNO", stu.SUPPLIERPARTSNO_VALUE));
                }
                if (stu.PARTSNAME_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" PartsName=@PartsName,");
                    sqlCmd.Parameters.Add(new SqlParameter("@PARTSNAME", stu.PARTSNAME_VALUE));
                }
                if (stu.PARTSDISPLAYNAME_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" PartsDisplayName=@PartsDisplayName,");
                    sqlCmd.Parameters.Add(new SqlParameter("@PARTSDISPLAYNAME", stu.PARTSDISPLAYNAME_VALUE));
                }
                if (stu.MATERIALSPECIFICATION_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" MaterialSpecification=@MaterialSpecification,");
                    sqlCmd.Parameters.Add(new SqlParameter("@MATERIALSPECIFICATION", stu.MATERIALSPECIFICATION_VALUE));
                }
                if (stu.PROCUREMENTPRICE_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" ProcurementPrice=@ProcurementPrice,");
                    sqlCmd.Parameters.Add(new SqlParameter("@PROCUREMENTPRICE", stu.PROCUREMENTPRICE_VALUE));
                }
                if (stu.PROCUREMENTCURRENCY_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" ProcurementCurrency=@ProcurementCurrency,");
                    sqlCmd.Parameters.Add(new SqlParameter("@PROCUREMENTCURRENCY", stu.PROCUREMENTCURRENCY_VALUE));
                }
                if (stu.MARKETPRICE_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" MarketPrice=@MarketPrice,");
                    sqlCmd.Parameters.Add(new SqlParameter("@MARKETPRICE", stu.MARKETPRICE_VALUE));
                }
                if (stu.MARKETCURRENCY_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" MarketCurrency=@MarketCurrency,");
                    sqlCmd.Parameters.Add(new SqlParameter("@MARKETCURRENCY", stu.MARKETCURRENCY_VALUE));
                }
                if (stu.GETGOODSDAYS_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" GetGoodsDays=@GetGoodsDays,");
                    sqlCmd.Parameters.Add(new SqlParameter("@GETGOODSDAYS", stu.GETGOODSDAYS_VALUE));
                }
                if (stu.PAYGOODSDAYS_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" PayGoodsDays=@PayGoodsDays,");
                    sqlCmd.Parameters.Add(new SqlParameter("@PAYGOODSDAYS", stu.PAYGOODSDAYS_VALUE));
                }
                if (stu.STOCKQUANTITY_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" StockQuantity=@StockQuantity,");
                    sqlCmd.Parameters.Add(new SqlParameter("@STOCKQUANTITY", stu.STOCKQUANTITY_VALUE));
                }
                if (stu.LEASTSELLCOUNT_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" LeastSellCount=@LeastSellCount,");
                    sqlCmd.Parameters.Add(new SqlParameter("@LeastSellCount", stu.LEASTSELLCOUNT_VALUE));
                }
                if (stu.REMARK_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" Remark=@Remark,");
                    sqlCmd.Parameters.Add(new SqlParameter("@REMARK", stu.REMARK_VALUE));
                }
                if (stu.ISAVAILABLE_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" IsAvailable=@IsAvailable,");
                    sqlCmd.Parameters.Add(new SqlParameter("@ISAVAILABLE", stu.ISAVAILABLE_VALUE));
                }
                if (stu.CREATEBY_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" CreateBy=@CreateBy,");
                    sqlCmd.Parameters.Add(new SqlParameter("@CREATEBY", stu.CREATEBY_VALUE));
                }
                if (stu.CREATETIME_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" CreateTime=@CreateTime,");
                    sqlCmd.Parameters.Add(new SqlParameter("@CREATETIME", stu.CREATETIME_VALUE));
                }
                if (stu.LASTMODIFYBY_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" LastModifyBy=@LastModifyBy,");
                    sqlCmd.Parameters.Add(new SqlParameter("@LASTMODIFYBY", stu.LASTMODIFYBY_VALUE));
                }
                if (stu.LASTMODIFYTIME_VALUE != DBNull.Value)
                {

                    sqlSb.Append(" LastModifyTime=@LastModifyTime,");
                    sqlCmd.Parameters.Add(new SqlParameter("@LASTMODIFYTIME", stu.LASTMODIFYTIME_VALUE));
                }

                var sql = sqlSb.ToString().TrimEnd(',');

                sqlCmd.Parameters.Add(new SqlParameter("@ID", stu.ID_VALUE));
                //sqlCmd.CommandText = sqlSb.ToString();
                //sqlCmd.ExecuteNonQuery();
                int i = base.ExecuteSQL(sql + " WHERE ID=@ID");

                return i;

                #endregion
            }
            else
            {
                //动作参数
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.ACTION_PARM, SqlDbType.VarChar, 20));
                //错误信息参数
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.ERRMSG_PARM, SqlDbType.VarChar, 100));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.OUTID_PARM, SqlDbType.Int));
                ////表字段参数
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.IDPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.GUIDPARM, SqlDbType.VarChar));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.CATEGORYIDPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.PARTSSUPPLIERIDPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.WISETECHPARTSNOPARM, SqlDbType.VarChar,
                    30));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.SUPPLIERPARTSNOPARM, SqlDbType.VarChar,
                    30));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.PARTSNAMEPARM, SqlDbType.VarChar, 100));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.PARTSDISPLAYNAMEPARM, SqlDbType.VarChar,
                    100));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.MATERIALSPECIFICATIONPARM,
                    SqlDbType.VarChar, 200));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.PROCUREMENTPRICEPARM, SqlDbType.Decimal));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.PROCUREMENTCURRENCYPARM,
                    SqlDbType.VarChar, 10));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.MARKETPRICEPARM, SqlDbType.Decimal));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.MARKETCURRENCYPARM, SqlDbType.VarChar,
                    10));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.GETGOODSDAYSPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.PAYGOODSDAYSPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.STOCKQUANTITYPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.LEASTSELLCOUNTPARM, SqlDbType.Int));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.REMARKPARM, SqlDbType.VarChar, 200));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.ISAVAILABLEPARM, SqlDbType.Bit));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.CREATEBYPARM, SqlDbType.VarChar, 20));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.CREATETIMEPARM, SqlDbType.DateTime));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.LASTMODIFYBYPARM, SqlDbType.VarChar, 20));
                this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditParts.LASTMODIFYTIMEPARM, SqlDbType.DateTime));



                this.sqlCmd.Parameters[CRM.MODEL.EditParts.ACTION_PARM].Value = stu.ACTION_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.ERRMSG_PARM].Direction = ParameterDirection.Output;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.OUTID_PARM].Direction = ParameterDirection.Output;
                //设置参数的值
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.IDPARM].Value = stu.ID_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.GUIDPARM].Value = stu.GUID_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.CATEGORYIDPARM].Value = stu.CATEGORYID_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.PARTSSUPPLIERIDPARM].Value = stu.PARTSSUPPLIERID_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.WISETECHPARTSNOPARM].Value = stu.WISETECHPARTSNO_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.SUPPLIERPARTSNOPARM].Value = stu.SUPPLIERPARTSNO_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.PARTSNAMEPARM].Value = stu.PARTSNAME_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.PARTSDISPLAYNAMEPARM].Value = stu.PARTSDISPLAYNAME_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.MATERIALSPECIFICATIONPARM].Value =
                    stu.MATERIALSPECIFICATION_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.PROCUREMENTPRICEPARM].Value = stu.PROCUREMENTPRICE_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.PROCUREMENTCURRENCYPARM].Value =
                    stu.PROCUREMENTCURRENCY_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.MARKETPRICEPARM].Value = stu.MARKETPRICE_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.MARKETCURRENCYPARM].Value = stu.MARKETCURRENCY_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.GETGOODSDAYSPARM].Value = stu.GETGOODSDAYS_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.PAYGOODSDAYSPARM].Value = stu.PAYGOODSDAYS_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.STOCKQUANTITYPARM].Value = stu.STOCKQUANTITY_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.LEASTSELLCOUNTPARM].Value = stu.LEASTSELLCOUNT_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.REMARKPARM].Value = stu.REMARK_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.ISAVAILABLEPARM].Value = stu.ISAVAILABLE_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.CREATEBYPARM].Value = stu.CREATEBY_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.CREATETIMEPARM].Value = stu.CREATETIME_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.LASTMODIFYBYPARM].Value = stu.LASTMODIFYBY_VALUE;
                this.sqlCmd.Parameters[CRM.MODEL.EditParts.LASTMODIFYTIMEPARM].Value = stu.LASTMODIFYTIME_VALUE;

                int i = this.ExecuteProcedure("dbo.Pro_EditParts"); //执行	
                //获取数据库的信息
                stu.ERRMSG_VALUE = this.sqlCmd.Parameters[CRM.MODEL.EditParts.ERRMSG_PARM].Value;
                return i;
            }
        }

        #endregion
    }
}